//
//  JourneyDetailHeaderView.m
//  WildDonkey
//
//  Created by 孙俊 on 15/3/31.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "JourneyDetailHeaderView.h"

@implementation JourneyDetailHeaderView

- (void)dealloc
{
	[_title release];
	[_author release];
	[_data release];
	[super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
	self = [super initWithFrame:frame];
	if (self) {
		
		CGRect rect = [UIScreen mainScreen].bounds;
		
		CGFloat width = rect.size.width;
		CGFloat height = rect.size.height;
		
		//背景视图 view
		UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, height / 4)];
		
		CGFloat bgViewHeight = bgView.bounds.size.height;
		
		//标题 label
		_title = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, width - 30, bgViewHeight / 4)];
		[_title setBackgroundColor:[UIColor redColor]];
		[bgView addSubview:_title];
		
		CGFloat titleHeight = _title.bounds.size.height;
		
		//作者 label
		_author = [[UILabel alloc] initWithFrame:CGRectMake(10, titleHeight + 10, width - 30, bgViewHeight / 4)];
		[_author setBackgroundColor:[UIColor redColor]];
		[bgView addSubview:_author];
		
		//评论/图片数 label
		_viewsImgcount = [[UILabel alloc] initWithFrame:CGRectMake(10, titleHeight * 2 + 10, width - 30, bgViewHeight / 4)];
		[_viewsImgcount setBackgroundColor:[UIColor redColor]];
		[bgView addSubview:_viewsImgcount];
		
		
	}
	return self;
}

- (void)setData:(JourneyDetailData *)data
{
	if (_data != data) {
		[_data release];
		_data = [data retain];
		
		_title.text = data.title;
		_author.text = data.author;
		
		//浏览数和图片数集成
		NSString *temp = [NSString stringWithFormat:@"%d 浏览 / %d 图片",data.views,data.imgcount];
		
		_viewsImgcount.text = temp;
		
	}
}











/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
